#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
int main()
{
	int n, y, r, s = 0;
	scanf("%d/%d/%d", &n, &y, &r);
	int t[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	int x[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
	if ((n % 4 == 0 && n % 100 != 0) || (n % 400 == 0))
	{
		for (int i = 0; i < y - 1; i++) s = s + t[i];
		s = s + r;
	}
	else
	{
		for (int i = 0; i < y - 1; i++) s = s + x[i];
		s = s + r;
	}
	printf("%d", s);
	return 0;
}